/*
 * This method controls the language of the site set by the user.
 */
package controllers.classes;

import classes.Url;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Achie
 */
public class LanguageController extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String language = request.getParameter("lang"); //selected language by the user
        HttpSession ses = request.getSession();

        //set the language depending on the choice (set the attribute language either case)
        if (language.equals("dutch")) {
            ses.setAttribute("language", "dutch");
        } else { //set english if otherwise/default
            ses.setAttribute("language", "english");
        }

        //redirect the user back to where he was
        response.sendRedirect(Url.getHistory());
        return;
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
